<!-- 父组件 Parent.vue -->
<template>
  <Child :message="parentMsg" :user="{ name: '张三', age: 25 }" />
</template>

<script setup>
import Child from './Child.vue';
import { ref } from 'vue';
const parentMsg = ref('这是父组件传递的消息');
</script>

<!-- 子组件 Child.vue -->
<template>
  <div>
    <p>接收的字符串：{{ message }}</p>
    <p>接收的对象：{{ user.name }} - {{ user.age }}</p>
  </div>
</template>

<script setup>
const props = defineProps({
  message: {
    type: String,
    required: true, // 必传校验
    default: '默认消息' // 可选默认值
  },
  user: {
    type: Object,
    required: false
  }
});
</script>